﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

<script type="text/javascript">
    //    function onfilter(theform) {
    //        if (theform.fileData.value == "") {
    //            alert("请点击浏览按钮，选择您要上传的压缩包类型文件!")
    //            return (false);
    //        }
    //        else {
    //            str = theform.fileData.value;
    //            strs = str.toLowerCase();
    //            lens = strs.length;
    //            extname = strs.substring(lens - 4, lens);
    //            if (extname != ".rar") {
    //                alert("请选择压缩包类型文件!");
    //                return (false);
    //            }
    //        }
    //        return (true);
    //    }

    $(function() {
        var options = {
            type: "POST",
            url: '/Form/Upload',
            success: function(res) {
                alert(res);
                //                if (!restag.res) {
                //                    alert(restag.msg);
                //                }
                //                else {
                //                    alert("操作成功");
                //                    //$("#workarea-11-2").html(data);
                //                }
            }
        };

        $("#frmUpload").ajaxForm(options);
    }
    );


    function onfilter(thetag) {
        var theform = $(thetag).parent();
        var fileName = $(theform).children("#fileData").val();
        if (fileName == "") {
            alert("请点击浏览按钮，选择您要上传的压缩包类型文件!")
            return (false);
        }

        var lens = fileName.length;
        var externName = fileName.substring(lens - 4, lens);
        if (externName != ".rar") {
            alert("请选择压缩包类型文件!");
            return (false);
        }

        return (true);
    }
    
</script>

<div id="form_uploadify" style="padding-top: 40px; padding-left: 10px;">
    <% using (Html.BeginForm("Upload", "Form", FormMethod.Post, new { id = "frmUpload", enctype = "multipart/form-data" }))
       {%>
    <input id="fileData" name="fileData" type="file" />
    <input type="submit" value="上传" onclick="return onfilter(this)" />
    <%} %>
    <form action="as" enctype="multipart/form-data" id="">
    </form>
</div>
